import os
from huggingface_hub import InferenceClient

client = InferenceClient(
    provider="fal-ai",
    api_key=os.environ["HF_API_KEY"], # 从环境中读取
)

print("当前工作目录是：", os.getcwd())

with open("../img/cat.png", "rb") as image_file:
   input_image = image_file.read()

# output is a PIL.Image object
image = client.image_to_image(
    input_image,
    prompt="Turn the cat into a tiger.",
    model="black-forest-labs/FLUX.1-Kontext-dev",
)      

print("图像生成完成！")
image.save("output.png")  # 保存为文件
image.show()  # 可选：显示图片（如果你在支持 GUI 的环境中）